package com.feilx.changggou.order.service.impl;

import com.changgou.bean.PageVo;
import com.changgou.bean.Query;
import com.changgou.bean.QueryCondition;
import com.changgou.pojo.order.TbOrderEntity;
import com.changgou.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.feilx.changggou.order.dao.TbOrderDao;
import com.feilx.changggou.order.service.TbOrderService;


@Service("tbOrderService")
public class TbOrderServiceImpl extends ServiceImpl<TbOrderDao, TbOrderEntity> implements TbOrderService {

    @Override
    public PageVo queryPage(QueryCondition params) {
        IPage<TbOrderEntity> page = this.page(
                new Query<TbOrderEntity>().getPage(params),
                new QueryWrapper<TbOrderEntity>()
        );

        return new PageVo(page);
    }

    @Override
    public void updateOrderStatus(String outtradeno, String payTime, String transactionid) {
        TbOrderEntity order = this.getById(outtradeno);
        order.setPayTime(DateUtils.parse(payTime,DateUtils.DATE_TIME_PATTERN));
        order.setPayStatus("1"); // 设置支付状态 1
        order.setTransactionId(transactionid); // 设置交易流水号
        this.updateById(order); // 更新到数据库
    }

}
